package com.example.apidocserver.interfaces.facade;

import com.example.apidocserver.application.event.SystemEvent;
import com.example.apidocserver.domain.system.entity.AllEnum;
import com.example.apidocserver.infrastructure.aop.PermissionAnno;
import com.example.apidocserver.infrastructure.util.result.ResultData;
import com.example.apidocserver.infrastructure.util.result.ResultUtils;
import com.example.apidocserver.interfaces.dto.IdsDto;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 系统业务接口
 *
 * @author xyqlg
 */
@RestController
@RequestMapping("system")
public class SystemController {
    @Resource
    private SystemEvent systemEvent;

    @GetMapping("getAllEnum")
    public ResultData findAllEnum() {
        return ResultUtils.success(systemEvent.findAllEnum());
    }

    @PermissionAnno
    @PostMapping("upsertEnum")
    public ResultData upsertAllEnum(@RequestBody AllEnum allEnum) {
        return ResultUtils.success(systemEvent.upsertAllEnum(allEnum));
    }

    @DeleteMapping("allEnum/{id}")
    @PermissionAnno
    public ResultData deleteAllEnum(@PathVariable("id") Integer id) {
        return ResultUtils.success(systemEvent.deleteAllEnum(id));
    }

    @PostMapping("allEnum/getByTypeList")
    public ResultData getByTypeList(@RequestBody IdsDto ids) {
        return ResultUtils.success(systemEvent.getByTypeList(ids));
    }
}
